#!/usr/bin/perl -w
my %last_name = (
  fred      => 'flintstone',
  Wilma     => 'Flintstone',
  Barney    => 'Rubble',
  Betty     => 'rubble',
  'Bamm-Bamm' => 'Rubble',
  PEBBLES   => 'FLINTSTONE',
);
my @keys = sort {
    "\L$last_name{$a}" cmp "\L$last_name{$b}" # 按姓氏排序
    or
    "\L$a" cmp "\L$b"                        # 按名字排序
} keys % last_name;

foreach(@keys){
    print "$last_name{$_}, $_\n";               # 打印：Rubble,Bamm-Bamm
}
